const express = require("express")
const blogtype = require("../service/blogTypeService")
const { formatResponse } = require("../utils/tool")
    // const { UnknownError } = require("../utils/error")

// 分类
const router = express.Router()

// 添加
router.post("/", async function(req, res, next) {
    const result = await blogtype.addBlogType(req.body)
    res.send(result)

})

// 获取全部
router.get("/", async function(req, res, next) {
    const result = await blogtype.findAllBlogType()
    res.send(result)
})

// 修改一个
router.put("/:id", async function(req, res, next) {
    const result = await blogtype.putBlogType(req.params.id, req.body)
    res.send(result)
})

// 删除一个
router.delete("/:id", async function(req, res, next) {
    const result = await blogtype.deleteBlogType(req.params.id)
    res.send(result)
})

// 获取一个
router.get("/:id", async function(req, res, next) {
    const result = await blogtype.findOneBlogType(req.params.id)
    res.send(result)
})




module.exports = router